package com.vote.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.vote.dto.TopicDto;
import com.vote.entity.Topic;
import com.vote.entity.Vote;
import com.vote.mapper.TopicMapper;
import com.vote.service.ITopicService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.vote.service.IVoteService;
import com.vote.vo.TopicVo;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author vote group
 * @since 2020-04-08
 */
@Service
public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements ITopicService {
    @CachePut(value = "Topic")
    @Override
    public List<TopicVo> getTopics(TopicDto topicDto) {
        return this.baseMapper.getTopics(topicDto);
    }

    @CacheEvict(value = "Topic",allEntries=true)
    @Override
    public void insertTopic(Topic topic) {
        this.baseMapper.insert(topic);
    }
    @CacheEvict(value = "Topic",allEntries=true)
    @Override
    public void updateId(Topic topic) {
        this.baseMapper.updateById(topic);
    }
    @CacheEvict(value = "Topic",allEntries=true)
    @Override
    public void deleteByTid(Integer tid) {
        this.baseMapper.deleteById(tid);
    }
}
